<template>
  <div class="app">
    <h3>我是app组件</h3>
    <Suspense>
      <template v-slot:defaut>
        <child />
      </template>
      <template v-slot:fallback>
        <h3>稍等,加载中...</h3>
      </template>
    </Suspense>
  </div>
</template>

<script>
//这个demo会报错 <Suspense> is an experimental feature and its API will likely change.  原因不详

// import child from "./components/child.vue";
import { defineAsyncComponent } from "vue"; // 静态引入
const child = defineAsyncComponent(() => import("./components/child.vue")); // 异步引入

export default {
  name: "App",
  components: { child },
};
</script>

<style>
.app {
  background-color: #ccc;
  padding: 10px;
}
</style>